import { Controller, Get, Post, Body, Param, Query, UsePipes, Put, Delete, ValidationPipe, Logger } from '@nestjs/common';
import { ApiTags, ApiBody, ApiQuery, ApiOperation, ApiExtraModels, ApiResponse, getSchemaPath } from '@nestjs/swagger';
import { UsersService } from './users.service';
import { GetUserDto } from './dto/get-user.dto';
import { CreateUserDto } from './dto/create-user.dto';

@ApiTags('用户')
@Controller('users')
export class UsersController {
  private readonly logger = new Logger(UsersController.name); // 添加 Logger
  constructor(private readonly usersService: UsersService) { }

  @Get('getUsers')
  @ApiOperation({ summary: '查询用户（分页）' })
  findUser(@Query() getUserDto: GetUserDto) {
    return this.usersService.findUser(getUserDto);
  }

  @Post("addUser")
  @ApiOperation({ summary: '创建用户' })
  @ApiExtraModels(CreateUserDto)
  
  // @ApiBody({ type: AddUserDto }) // 指定请求体类型
  createUser(@Body() createUserDto: CreateUserDto) {
    return this.usersService.createUser(createUserDto);
  }
} 